class Stack{
    constructor(...agrs){
        this.data = [...agrs] 
    
    }
    pop(){
       if(this.empty) return
       return this.data.pop()
    }
    get top() {
        return this.data[this.size-1] 
    }
    get size(){
        return this.data.length ;
    }
    push(val){
        this.data.push(val)
    }

    get empty(){
        return this.data.length ===0 ;
    }
}



const m1 = { '/': true, '*': true }
const m2 = { '-': true, '+': true }
let stack = [] ;
/* 用n 记录数字开始的位置 */
for(let m =0, n=-1; m< s.length ;m++){
let w = s[m]
if(w === ' '){
    continue
}
if(m1[w] || m2[w]){
    stack.push(w)
}else {
    /* n为-1时 赋值m， 数字结束时 赋值-1 */
  n=n >-1? n:m ;

}
}
let s1 = s.split('')
console.log(s1)
let temp = [Number(s1[0])]
for (let i = 0; i < s1.length -1; i++) {
    let symbol = s1[i]
    temp.push(s1[i + 1])
    if (m1[symbol]) {
        let b = Number(temp.pop())
        temp.pop()
        let a = Number(temp.pop())
        console.log(a,symbol ,b)
        switch (symbol) {
            case '/':
                temp.push(a / b | 0)
                break;

            case '*':
                temp.push(a * b)

                break;
        }

    }

}
s1 = temp ;
temp = [s1[0]] ;
console.log(s1)
for (let i = 0; i < s1.length -1; i++) {
    const symbol = s1[i]
    temp.push(s1[i + 1])
    if (m2[symbol]) {
        let b = Number(temp.pop())
        temp.pop()
        let a = Number(temp.pop())
        console.log(a,symbol ,b)

        switch (symbol) {
            case '+':
                temp.push(a + b | 0)
                break;

            case '-':
                temp.push(a - b)

                break;
        }
    }

}

